package work20241120;


import java.util.Scanner;

/**
 * @author zdl
 * @date 2024/11/20
 */
public class Demo1 {
    public static void main(String[] args) {
        /**
         * 1.while循环练习：回文数
         * 需求：给你一个整数x，如果x是一个回文整数，打印true，否则返回false
         *     解释：回文数是指正序和倒序读都是一样的整数
         */
        Scanner sc =new Scanner(System.in);
        System.out.println("请输入一个整数:");
        int num = sc.nextInt();
        if(num < 0){
            System.out.println("不是回文数");
        }else{
            int yuanNum = num;
            int fanNum = 0;
            while (num != 0){
                int lastNum = num % 10;
                fanNum = fanNum * 10 +lastNum;
                num = num /10;
            }
            if (fanNum == yuanNum){
                System.out.println("是回文数");
            }else {
                System.out.println("不是回文数");
            }
        }

    }
}
